import java.io.UnsupportedEncodingException;

/**
 * Created by haiqiang on 17/10/1.
 */
public class demoJavaChar {
    public static void main(String[] args) throws UnsupportedEncodingException {
        String str = "hello";
        System.out.println(str.length());
        System.out.println(str.codePointCount(0, str.length()));

        String str1 = "支持郭文贵\uD834\uDF06";
        System.out.println(str1.length());
        System.out.println(str1.codePointCount(0, str1.length()));
        byte[] bytes = str1.getBytes("UTF-16");
        System.out.println(bytes.length);
        byte[] bytes1 = str1.getBytes("UTF-8");
        System.out.println(bytes1.length);

        int[] codePoints = str1.codePoints().toArray();
        for(int i = 0; i < codePoints.length; i++) {
            System.out.println(codePoints[i]);
        }

        System.out.println("\u4e00");
        codePoints = "\u4e00".codePoints().toArray();
        for (int i = 0; i < codePoints.length; i++) {
            System.out.println(codePoints[i]);
        }
        System.out.println("\u9fa5");

        char x = '龥';
        System.out.println(x);

    }
}
